home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0184_Drip Drip Drip.pas < prev    next >
Pascal/Delphi Source File  |  1995-02-28  |  3KB  |  87 lines

  1. { Drip revisited - Modifications by Christopher J. Chandra
  2.   Originally coded by Tim Mattison.
  3.   This version works much much faster than the last one.
  4.   I dunno if it is maximally optimized or not.  Speed Demons?? *Grin* }
  5.  
  6. uses crt;                               {386s needed for clrcrt procs}
  7.  
  8. const SEGA000:Word=$a000;               {needed for TP v6.0 or older}
  9.  
  10. var yt:array[0..200] of word;
  11.     timer:longint absolute $0040:$006c;
  12.     tstart,tend:longint;
  13.     xx,yy:word;
  14.  
  15. {You can use Drip and Drip2 interchangably?; both operates on the same
  16.  speed.  The difference is in the calculation of the pixel position}
  17.  
  18. procedure Drip;assembler;
  19. asm
  20.    mov es,SEGA000
  21.    mov dx,198                           {for dx:=198 downto 0 do}
  22. @reloop1:
  23.    xor si,si                            {for si:=0 to 319 do}
  24. @reloop2:
  25.    mov bx,dx;shl bx,1;mov di,word ptr[yt+bx];add di,si
  26.    mov al,[ES:DI]                       {al:=getcolor(si,dx}
  27.    mov bx,dx;inc bx;mov cx,200;sub cx,bx;
  28.    shl bx,1;mov di,word ptr[yt+bx];add di,si
  29. @again:                                 {for cx:=dx+1 to 200 do}
  30.    mov [ES:DI],al;add di,320            {putpixel(si,cx,al}
  31.    loop @again
  32.   inc si;cmp si,320;jl @reloop2         {end}
  33.   dec dx;jnz @reloop1;                  {end}
  34. end;
  35.  
  36. procedure Drip2;assembler;
  37. asm
  38.    mov es,SEGA000
  39.    mov dx,198                           {for dx:=198 downto 0 do}
  40. @reloop11:
  41.    xor si,si                            {for si:=0 to 319 do}
  42. @reloop22:
  43.    mov ax,dx;mov di,ax;shl ax,8;shl di,6;add di,ax;add di,si 
  44.    mov bl,[ES:DI]                       {bl:=getcolor(si,dx}
  45.    mov ax,dx;inc ax;mov cx,200;sub cx,ax
  46.    mov di,ax;shl ax,8;shl di,6;add di,ax;add di,si
  47. @again1:                                {for cx:=dx+1 to 200 do}
  48.    mov [ES:DI],bl;add di,320            {putpixel(si,cx,bl}
  49.    loop @again1
  50.   inc si;cmp si,320;jl @reloop22        {end}
  51.   dec dx;jnz @reloop11;                 {end}
  52. end;
  53.  
  54. begin
  55.  for xx:=0 to 200 do yt[xx]:=xx*320;    {prepare y table}
  56.  asm mov ax,$13;int 10h                 {init 320x200x256c graphic mode}
  57.   mov es,SEGA000;xor di,di;db $66;mov ax,$3232;dw $3232;mov cx,16000;db $66
  58.   rep stosw end;                        {fill screen w/ some sort of blue}
  59.  
  60.  for xx:=0 to 255 do                    {set palette}
  61.  begin
  62.   port[$3c8]:=xx;
  63.   port[$3c9]:=xx shr 3;port[$3c9]:=xx shr 2;port[$3c9]:=xx shr 1;
  64.  end;
  65.  
  66.  for yy:=50 to 199-50 do                {you can replace this w/ whatever}
  67.  for xx:=50 to 320-50 do                {thing that you want to drip}
  68.   mem[$a000:yt[yy]+xx]:=yy and 255 + random(xx shr 2);
  69.  
  70.  tstart:=timer;                         {begin timer}
  71.  drip2;                                 {apply dripping fx - drip/drip2}
  72.  tend:=timer;                           {stop timer}
  73.  
  74.  asm mov es,SEGA000;xor di,di;db $66;mov ax,$0000;dw $0000;mov cx,16000;
  75.   db $66;rep stosw                      {fill screen w/ black}
  76.   xor ax,ax;int 16h end;                {get a keystroke}
  77.  
  78.  textmode(co80);                        {return to textmode 80x25 color}
  79.  writeln(tend-tstart);                  {show time needed in microseconds}
  80. end.
  81.  
  82. {Enjoy - CJC}---
  83.  * Origin: The InterZone Cafe - Pembroke Pines FL USA (1:369/35)
  84. SEEN-BY: 135/52 94 292 416 369/14 32 35 69 74 92 101 135 137
  85. SEEN-BY: 369/169 396/1 3615/50 51
  86. PATH: 369/35 74 32 135/52 94 3615/50
  87.